#coding=utf-8
'''
Created on 2016年3月3日
'''
import zmq
__author__ = 'chenjian'

if __name__ == '__main__':
    context    = zmq.Context()
    subscriber = context.socket(zmq.SUB)
#     subscriber.bind("tcp://*:5564")
    subscriber.connect("tcp://localhost:5564")
    subscriber.setsockopt(zmq.SUBSCRIBE, b"B")

    while True:
        # Read envelope with address
        [address, contents] = subscriber.recv_multipart()
        print("[%s] %s" % (address, contents))